﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     ServiceKeyRela业务接口的实现
    /// 作者：     lwl
    /// 日期：     2011/10/14
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class ServiceKeyRelaSqlMapDao : BaseSqlMapDao, IServiceKeyRelaDao
    {
        private static ServiceKeyRelaSqlMapDao instance = null;
        private static object syncRoot = new object();

        private ServiceKeyRelaSqlMapDao()
        {
            //
            // TODO: 此处添加ServiceKeyRelaSqlMapDao的构造函数
            //
        }
        public static IServiceKeyRelaDao Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new ServiceKeyRelaSqlMapDao();
                        }
                    }
                }
                return instance;
            }
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectServiceKeyRelaByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<ServiceKeyRela> GetList()
        {
            try
            {
                return ExecuteQueryForList<ServiceKeyRela>("SelectServiceKeyRela", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<ServiceKeyRela> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<ServiceKeyRela>("SelectServiceKeyRelaByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="RelaID"></param>
        /// <returns></returns>
        public ServiceKeyRela GetDetail(System.String relaid)
        {
            try
            {
                return ExecuteQueryForObject<ServiceKeyRela>("SelectServiceKeyRela", relaid) as ServiceKeyRela;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="servicekeyrela"></param>
        /// <returns></returns>
        public object Add(ServiceKeyRela servicekeyrela)
        {
            //int id = GetId("ServiceKeyRela");
            //servicekeyrela.RelaID = id;

            try
            {
                return ExecuteInsert("InsertServiceKeyRela", servicekeyrela);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="servicekeyrela"></param>
        /// <returns></returns>
        public int Update(ServiceKeyRela servicekeyrela)
        {
            try
            {
                return ExecuteUpdate("UpdateServiceKeyRela", servicekeyrela);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="RelaID"></param>
        /// <returns></returns>
        public int Delete(System.String relaid)
        {
            try
            {
                return ExecuteDelete("DeleteServiceKeyRela", relaid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="servicekeyrela"></param>
        /// <returns></returns>
        public int Delete(ServiceKeyRela servicekeyrela)
        {
            try
            {
                return ExecuteDelete("DeleteServiceKeyRela", servicekeyrela.RelaID);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 批量禁用服务信息与关键字的关系 
        /// </summary>
        /// <param name="idlist"></param>
        /// <returns></returns>
        public int Disable(Hashtable ht)
        {
            try
            {
                return ExecuteUpdate("DisableServiceKeyRela", ht);
            }
            catch 
            {
                
                throw;
            }
        }
    }
}
